home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / config / i386-emul / switch.s < prev    next >
Text File  |  1996-10-24  |  3KB  |  120 lines

  1. #    (C) 1995-96 AROS - The Amiga Replacement OS
  2. #    $Id: switch.s,v 1.9 1996/10/24 15:51:13 aros Exp $
  3. #    $Log: switch.s,v $
  4. #    Revision 1.9  1996/10/24 15:51:13  aros
  5. #    Use the official AROS macros over the __AROS versions.
  6. #
  7. #    Revision 1.8  1996/10/23 08:04:26  aros
  8. #    Use generated offsets which makes porting much easier
  9. #
  10. #    Revision 1.7  1996/09/11 16:54:30    digulla
  11. #    Always use __AROS_SLIB_ENTRY() to access shared external symbols, because
  12. #    some systems name an external symbol "x" as "_x" and others as "x".
  13. #    (The problem arises with assembler symbols which might differ)
  14. #
  15. #    Revision 1.6  1996/09/11 14:41:17    digulla
  16. #    Removed tick which made problems with CPP
  17. #    Closed comment
  18. #
  19. #    Revision 1.5  1996/08/23 16:49:22    digulla
  20. #    With some systems, .align 16 aligns to 64K instead of 16bytes. Therefore
  21. #    I replaced it with .balign which does what we want.
  22. #
  23. #    Revision 1.4  1996/08/13 14:03:20    digulla
  24. #    Added standard headers
  25. #
  26. #    Revision 1.3  1996/08/01 17:48:52    digulla
  27. #    Added description
  28. #
  29. #    Revision 1.2  1996/08/01 17:41:26    digulla
  30. #    Added standard header for all files
  31. #
  32. #    Desc:
  33. #    Lang:
  34.  
  35. #*****************************************************************************
  36. #
  37. #   NAME
  38. #
  39. #    AROS_LH0(void, Switch,
  40. #
  41. #   LOCATION
  42. #    struct ExecBase *, SysBase, 6, Exec)
  43. #
  44. #   FUNCTION
  45. #    Tries to switch to the first task in the ready list. This
  46. #    function works almost like Dispatch() with the slight difference
  47. #    that it may be called at any time and as often as you want and
  48. #    that it does not lose the current task if it is of type TS_RUN.
  49. #
  50. #   INPUTS
  51. #
  52. #   RESULT
  53. #
  54. #   NOTES
  55. #    This function is CPU dependant.
  56. #
  57. #    This function is for internal use by exec only.
  58. #
  59. #    This function preserves all registers.
  60. #
  61. #   EXAMPLE
  62. #
  63. #   BUGS
  64. #
  65. #   SEE ALSO
  66. #    Dispatch()
  67. #
  68. #   INTERNALS
  69. #
  70. #   HISTORY
  71. #
  72. #******************************************************************************
  73.  
  74.     .include "machine.i"
  75.  
  76.     .text
  77.     .balign 16
  78.     .globl    _Exec_Switch
  79.     .type    _Exec_Switch,@function
  80. _Exec_Switch:
  81.     /* Make room for Dispatch() address. */
  82.     subl    $4,%esp
  83.  
  84.     /* Preserve registers */
  85.     pushl    %eax
  86.     pushl    %ebx
  87.     pushl    %ecx
  88.     pushl    %edx
  89.  
  90.     /* Get SysBase */
  91.     movl    24(%esp),%ebx
  92.  
  93.     /* If current state is TS_RUN and TF_EXCEPT is 0... */
  94.     movl    ThisTask(%ebx),%ecx
  95.     movw    tc_Flags(%ecx),%eax
  96.     andb    $TF_EXCEPT,%al
  97.     cmpw    $TS_RUN*256,%ax
  98.     jne    disp
  99.  
  100.     /* ...move task to the ready list */
  101.     movb    $TS_READY,tc_State(%ecx)
  102.     leal    Enqueue(%ebx),%edx
  103.     pushl    %ebx
  104.     pushl    %ecx
  105.     leal    TaskReady(%ebx),%eax
  106.     pushl    %eax
  107.     call    *%edx
  108.     addl    $12,%esp
  109.  
  110.     /* Prepare dispatch */
  111. disp:    leal    Dispatch(%ebx),%eax
  112.     movl    %eax,16(%esp)
  113.  
  114.     /* restore registers and dispatch */
  115.     popl    %edx
  116.     popl    %ecx
  117.     popl    %ebx
  118.     popl    %eax
  119.     ret
  120.